package com.senjoeson.netlib.http;

import java.io.IOException;

import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;

/**
 * @author sunqiao
 * @date 2018/7/12 14:48
 */

public class OkhttpCallBack implements Callback {

    private CallBack mCallback;


    public OkhttpCallBack(CallBack callback) {
        mCallback = callback;
    }

    @Override
    public void onFailure(Call call, IOException e) {

        mCallback.onFailure(e.getMessage());

    }

    @Override
    public void onResponse(Call call, Response response) throws IOException {
        mCallback.onSuccess(response.body().string());
    }
}
